package com.dries.portal.module.chat.controller;

import com.dries.common.api.CommonResult;
import com.dries.portal.module.chat.constants.ChatConstant;
import com.dries.security.service.RedisService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import java.util.Map;
import java.util.concurrent.ConcurrentHashMap;

/**
 * @author Dries
 * @email 1451691457@qq.com
 */
@RestController
@RequestMapping("/ws")
@Slf4j
public class SocketController {

    public static Map<Long, String> img = new ConcurrentHashMap<>();

    @Resource
    private RedisService redisService;

    /**
     * 获取房间里的用户
     */
    @GetMapping("/online/{room}")
    public CommonResult online(@PathVariable String room) {

        Map<Object, Object> map = redisService.hGetAll(ChatConstant.CHAT_GROUP_ONLINE_KEY + room);

        return CommonResult.success(map);
    }

    /**
     * 判断昵称在某个房间中是否已存在，房间是否有密码，如果有，用户输入的密码又是否正确
     *
     * @param room     房间号
     * @param nickName 用户名
     * @param pwd      房间密码
     * @return
     */
    @PostMapping("/judgeNick")
    public void judgeNick(String room, String nickName, String pwd) {
    }

    /**
     * 获取所有房间
     *
     * @return
     */
    @GetMapping("/allRoom")
    public Map<String, Object> allRoom() {
        return null;
    }

}
